package him.control;

import him.action.Action;
import him.action.ActionFactory;
import him.action.ActionForward;
import him.action.factory.MemberActionFactory;

import java.io.IOException;
import java.io.UnsupportedEncodingException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class MemberControl
 */
public class MemberControl extends HttpServlet {
	private static final long serialVersionUID = 1L;

    public MemberControl() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doprocess(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doprocess(request,response);
	}

	private void doprocess(HttpServletRequest request,
			HttpServletResponse response) throws IOException, ServletException {
		request.setCharacterEncoding("euc-kr");
		response.setContentType("text/html; charset=euc-kr");
	
		Action action;
		ActionFactory factory=MemberActionFactory.getInstance();
		
		action = factory.getAction(request.getParameter("command"));
		ActionForward forward = action.execute(request, response);
		forward.go(request, response);
	}

}
